package co.com.javeriana.aes.patrones.universalbank.mainframe.wrapper.service;

import co.com.javeriana.aes.patrones.universalbank.dto.WrapperList;
import co.com.javeriana.aes.patrones.universalbank.dto.Account;
import co.com.javeriana.aes.patrones.universalbank.mainframe.client.MainFrameClient;
import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.ejb.Stateless;

/**
 *
 * @author jonathan
 */
@WebService(serviceName = "MainFrameService")
@Stateless()
public class MainFrameService {

    /**
     * This is a sample web service operation
     *
     * @param userId
     * @param accountNumber
     * @param discountValue
     * @return
     */
    @WebMethod(operationName = "discount")
    public String discount(@WebParam(name = "userId") String userId, @WebParam(name = "accountNumber") String accountNumber, @WebParam(name = "discountValue") String discountValue) {

        StringBuilder sb = new StringBuilder();
        sb.append("U");
        sb.append(userId);
        sb.append(",");
        sb.append(accountNumber);
        sb.append(",");
        sb.append(discountValue);

        return MainFrameClient.processDisscount(sb.toString());
        //U1136879159,200458835,17"
    }

    /**
     * This is a sample web service operation
     *
     * @param userId
     * @return
     */
    @WebMethod(operationName = "getAccounts")
    public WrapperList getAccounts(@WebParam(name = "userId") String userId) {
//        System.out.println("perro "+userId);
//        MainFrameClient.processAccounts("1136879159");
//        //List<Account> aa = co.com.javeriana.aes.patrones.universalbank.mainframe.client.MainFrameClient.processAccounts(userId);
////        for (Account account : aa) {
////            System.out.println(account.getAcountId());
////        }
//
        //return (Object[])MainFrameClient.processAccounts(userId);
        return MainFrameClient.processAccounts(userId);
        //MainFrameClient.processAccounts(userId);
           // return new co.com.javeriana.aes.patrones.universalbank.dto.WrapperList( MainFrameClient.processAccounts(userId));

            
    }
   
}
